﻿#region File and License Information
/*
<File>
	<License>
		Copyright © 2009 - 2017, Daniel Vaughan. All rights reserved.
		This file is part of Calcium (http://calciumsdk.net), 
		which is released under the MIT License.
		See file /Documentation/License.txt for details.
	</License>
	<CreationDate>2010-11-26 11:56:06Z</CreationDate>
</File>
*/
#endregion

using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;

#if WINDOWS_UWP
using Windows.Security.ExchangeActiveSyncProvisioning;
#endif

namespace Outcoder.UI.Xaml
{
	public partial class EnvironmentValues : INotifyPropertyChanged
	{
		static bool? designTime;

		public static bool DesignTime
		{
			get
			{
				if (!designTime.HasValue)
				{
#if SILVERLIGHT
					designTime = DesignerProperties.IsInDesignTool;
#elif NETFX_CORE
					designTime = global::Windows.ApplicationModel.DesignMode.DesignModeEnabled;
#elif MONODROID || MONOTOUCH
					designTime = false;
#else
					designTime = (bool)DesignerProperties.IsInDesignModeProperty.GetMetadata(
						typeof(System.Windows.DependencyObject)).DefaultValue;
#endif
				}

				return designTime.Value;
			}
		}

#if WINDOWS_PHONE
		static bool? usingEmulator;

		public static bool UsingEmulator
		{
			get
			{
				if (!usingEmulator.HasValue)
				{
					usingEmulator = Microsoft.Devices.Environment.DeviceType 
						== Microsoft.Devices.DeviceType.Emulator;
				}
				return usingEmulator.Value;
			}
		}

		static bool? usingDevice;

		[Obsolete("Please use !UsingEmulator instead.")]
		public static bool UsingDevice
		{
			get
			{
				if (!usingDevice.HasValue)
				{
					usingDevice = Microsoft.Devices.Environment.DeviceType 
						== Microsoft.Devices.DeviceType.Device;
				}
				return usingDevice.Value;
			}
		}
#endif

#if WINDOWS_UWP
		static readonly EasClientDeviceInformation deviceInfo = new EasClientDeviceInformation();
		static bool? usingEmulator;
		
		public static bool UsingEmulator
		{
			get
			{
				if (!usingEmulator.HasValue)
				{
					usingEmulator = deviceInfo.SystemProductName == "Virtual";
				}
				return usingEmulator.Value;
			}
		}
#endif

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void OnPropertyChanged([CallerMemberName]string propertyName = null)
		{
			PropertyChangedEventHandler handler = PropertyChanged;
			if (handler != null)
			{
				handler(this, new PropertyChangedEventArgs(propertyName));
			}
		}
	}
}
